Motion Sensor Program

I everyone :smiley: I’ve written a SmartApp that turns on a light when motion is detected between time x and time y. If no motion is detected, the light turns off.
Here’s my code: http://pastebin.com/b3Le0Eqz
I was wondering if my last method is valid. I’m now sure how to compare values or add values to now(). Everything else is working, if someone could tell me if the code should work in terms of turning off m minutes after motion stopped that would be awesome. Thanks sooooooo much to anyone that tries to help in advance.