this logic needs an explaination