This needs to be refactored in general case. Ok for now.