added a checking to the resources amount