fixed last seen time, cleaned code