bugfix to assign default color to marker, restructuring code