fixed a crashing bug and cleaned up code a little bit in main.lua. not sure how I fixed it lol