Solution to N + 1 queries problem and small fix ability (Close #12)