tabs --> spaces
collapsed confusing functions called from a single place