added comments probably would be better to make two different script files one for manual and one for automatic function