converted to use calendar:local_time() instead of erlang:now()