Commented and added better return values