fixed bugs & added php queries