Fixed queries and made transaction fully working