Added brackets and typecheck as requested