Added braces
Added memory bounds clipping