refactored and made changes to basic.lua