cleaned up code using frames