Fixed username empty string error and added content type check