streamlined code a bit