Fixed reshape function