cleaned up code and fixed y text field bug