Fix problem with ternary operator and add reasonable names to methods