Added helper to main, fixed bugs in helper