Integrated formula input box, cleaned code