moved most coding to separete script