working code with most necessary commands.