updated with more optimized methods.