revamped code, and simplified app