simplified the return and added encoding