seperated the main function from the frontend