Refactor to minimize erros