edited dan's terrible coding