copy and syntax errors fixed as suggested by @ChaosBelcebub