striped unnecessary information from query
added getIntervallQuery function
switched from manual to dynamic query generation