Added short comments explaining each function