hopefully cleaning up the code and not breaking anything