simplified some code to make things more responsive